package lock;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author jiangwz
 * @create 2021/2/18.
 */
public class AqsDebugTest {
    ReentrantLock lock = new ReentrantLock();
    private int count;

    public void noLock(){
        System.out.println("count =" + ++count);
    }
    public synchronized void lock(){
        System.out.println("count =" + ++count);
    }
    public  void reentrantLock(){
        lock.lock();
        System.out.println("count =" + ++count);
//        lock.unlock();
    }

    public static void main(String[] args) throws InterruptedException {

        AqsDebugTest test = new AqsDebugTest();
        for (int i = 0; i < 3; i++) {
            TimeUnit.SECONDS.sleep(1);
            new Thread(() -> {
                test.reentrantLock();
            }, ""+i).start();
        }



    }
}
